package com.yeyv.net.Web.Service.Implement;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeyv.net.Web.Entity.OpensourceCalendarEntity;
import com.yeyv.net.Web.Mapper.OCMapper;
import com.yeyv.net.Web.Service.OCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OCServiceImpl extends ServiceImpl<OCMapper, OpensourceCalendarEntity> implements OCService {

    @Autowired
    private OCMapper ocMapper;

    @Override
    public List<OpensourceCalendarEntity> getBaseOC() {
        return ocMapper.selectList(new LambdaQueryWrapper<OpensourceCalendarEntity>()
                .eq(OpensourceCalendarEntity::getBaseId, -1)
                .groupBy(OpensourceCalendarEntity::getFileName)
        );
    }

    @Override
    public List<OpensourceCalendarEntity> getDirVersions(String dirName) {
        return ocMapper.selectList(new LambdaQueryWrapper<OpensourceCalendarEntity>()
                .eq(OpensourceCalendarEntity::getFileName, dirName));
    }

    @Override
    public List<OpensourceCalendarEntity> getDirList(int id) {
        return ocMapper.selectList(new LambdaQueryWrapper<OpensourceCalendarEntity>()
                .eq(OpensourceCalendarEntity::getBaseId, id)
        );
    }
}
